<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Banner图片切换</title>
    <link rel="stylesheet" href="./css/index.css" />
    <style>
      .s1{
        width: 100px;
        height: 100px;
        position: absolute;
        top:5%;
        left:5%

      }
      .active{
        display: none;
      }
    </style>
  </head>

  <body>
    <div id="mask">
      <div class="center">
        <h2 class="title">天猫双十二惊喜袭来</h2>
        <img v-bind:src='imgsrc' alt="未正确加载图片资源" />
        <a
          href="javascript:void(0)"
          class="left"
          @click='pre'
        >
          <img src="./images/left.png" alt="" v-show="isShow1"/>
        </a>
       
        <a
          href="javascript:void(0)"
          class="right"
          @click='next'
        >
          <img src="./images/right.png" alt=""  v-show="isShow2"/>
        </a>
      </div>
    </div>

    <script src="../js/vue.js"></script>
    <script>
      let app = new Vue({
        el: "#mask",
        data: {
          src:['./images/01.jpg','./images/02.jpg','./images/03.jpg','./images/04.jpg'],
          imgsrc:'./images/01.jpg',
          index:0,
          isShow1:false,
          isShow2:true

        },
        methods: {
          next()
          {
            this.isShow1=true;
            if(this.index!=3){
            this.index=this.index+1;
            this.imgsrc=this.src[this.index];}
            if(this.index==3){
              this.isShow2=false;
            }
           

          },
          pre()
          {
            this.isShow2=true;
            if(this.index!=0){
            this.index=this.index-1;
            this.imgsrc=this.src[this.index];
            }
            if(this.index==0){
              this.isShow1=false;
            }

            
          },
        }
      });
    </script>
  </body>
</html> 